package com.lj.app.controller;

import com.lj.common_web.annotation.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import org.springframework.web.bind.annotation.*;

/**
 * @author luojing
 * @since 2024/8/9 18:42
 */
@RestController
@ResponseResultVo
@RequestMapping("/test/")
@Tag(name = "测试api")
public class TestController {

    @GetMapping("/sayHello")
    @Operation(summary = "测试接口", description = "测试接口")
    @SysLog("测试接口")
    @RateLimit(limit = 5, timeout = 5)
    public String sayHello() {
        return "hello";
    }

    /**
     * 测试签名逻辑
     * 可以将{@link com.lj.common_web.filter.SimpleVerifySignature} 注入到容器中，
     * 并配置 lu-admin.sign.api.urlPatterns 需要校验签名的接口为/test/testSign即可测试
     * <p>
     * {@link RequestBodyDecrypt } 是接口解密注解,具体解密逻辑请参照SimpleRequestMessageHandler 或者自定义
     */
    @PostMapping("/testSign")
    @Operation(summary = "测试签名", description = "测试签名")
    @RequestBodyDecrypt(decipher = AesResponseBodyEncipher.class)
    @ResponseBodyEncrypt(encipher = AesResponseBodyEncipher.class)
    public TestModel testSign(@RequestBody TestModel model) {
        System.out.println(model);
        return model;
    }

    @Data
    public static class TestModel {
        private String userName;
        private Integer age;
    }


}
